package com.tadpole.music.holder.study;

import android.annotation.SuppressLint;
import android.view.View;
import android.widget.TextView;

import com.tadpole.music.R;
import com.tadpole.music.adapter.base.BaseAdapter;
import com.tadpole.music.bean.study.MoNiQuestionErrorBean;
import com.tadpole.music.holder.base.BaseViewHolder;
import com.tadpole.music.utils.NoDoubleClickListener;

import java.util.List;

/**
 * Created By 孙岩
 * on 2020/9/29
 */
public class MoNiErrorViewHolder extends BaseViewHolder {
    private List<MoNiQuestionErrorBean.DataBeanX.DataBean> list;
    private View itemView;
    //名称
    private TextView tvName;
    //分数
    private TextView tvCount;
    //正确率
    private TextView tvAccuracy;
    //时长
    private TextView tvTime;
    //时间
    private TextView tvDate;
    //重新测试
    private TextView tvAgain;
    //查看错题
    private TextView tvSeeError;
    private BaseAdapter.OnChildClickListener onChildClickListener;
    public MoNiErrorViewHolder(View itemView,List<MoNiQuestionErrorBean.DataBeanX.DataBean> list,BaseAdapter.OnChildClickListener onChildClickListener) {
        super(itemView);
        this.itemView = itemView;
        this.list = list;
        this.onChildClickListener = onChildClickListener;
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void init(final int position) {
        tvName = itemView.findViewById(R.id.tvName);
        tvCount = itemView.findViewById(R.id.tvCount);
        tvAccuracy = itemView.findViewById(R.id.tvAccuracy);
        tvTime = itemView.findViewById(R.id.tvTime);
        tvDate = itemView.findViewById(R.id.tvDate);
        tvAgain = itemView.findViewById(R.id.tvAgain);
        tvSeeError = itemView.findViewById(R.id.tvSeeError);

        tvName.setText(list.get(position).getRank()+"----"+list.get(position).getClassX());
        tvCount.setText((list.get(position).getNum()*10)+"");
        double a = ((double)(10 - list.get(position).getNum()) / 10);
        tvAccuracy.setText("正确率："+ a*100+"%");
        tvTime.setText("时长："+list.get(position).getTime()+"分钟");
        tvDate.setText(list.get(position).getCreated_at());

        tvAgain.setOnClickListener(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                onChildClickListener.onChildClick(tvAgain,position);
            }
        });

        tvSeeError.setOnClickListener(new NoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                onChildClickListener.onChildClick(tvSeeError,position);
            }
        });
    }
}
